package com.estar.assistsurvy.activity;

import java.util.ArrayList;
import java.util.List;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.route.BikingRouteResult;
import com.baidu.mapapi.search.route.DrivingRoutePlanOption;
import com.baidu.mapapi.search.route.DrivingRouteResult;
import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener;
import com.baidu.mapapi.search.route.PlanNode;
import com.baidu.mapapi.search.route.RoutePlanSearch;
import com.baidu.mapapi.search.route.TransitRouteResult;
import com.baidu.mapapi.search.route.WalkingRouteResult;
import com.estar.app.appsrvycabx.domain.DataVO;
import com.estar.app.appsrvyspds.domain.ReturnSubVideoSrvyVO;
import com.estar.app.appsrvyspds.domain.SubmitVideoSrvyVO;
import com.estar.assistsurvy.R;
import com.estar.assistsurvy.constant.Constants;
import com.estar.assistsurvy.entity.RequestAbond;
import com.estar.assistsurvy.entity.RequestGrab;
import com.estar.assistsurvy.entity.ResponseMsg;
import com.estar.assistsurvy.entity.VOBase;
import com.estar.assistsurvy.entity.grabPondList;
import com.estar.assistsurvy.thread.AbondOrderThread;
import com.estar.assistsurvy.thread.GrabOrderThread;
import com.estar.assistsurvy.thread.PhotoThread;
import com.estar.assistsurvy.thread.VideoThread;
import com.estar.assistsurvy.entity.grabList;
import com.estar.assistsurvy.utils.DrivingRouteOverlay;
import com.estar.assistsurvy.utils.ExitUtils;
import com.estar.assistsurvy.utils.MightypleUtil;
import com.estar.assistsurvy.utils.TimeUtils;
import com.estar.assistsurvy.utils.VoiceUtil;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class OrderConfirmActivity extends BaseActivity implements OnClickListener,OnGetRoutePlanResultListener{

	private Intent intent;
	private String deviceId,orderType,phoneNumber;
	private grabList grbaOrder;
	private grabPondList grbaPondOrder;

	private TextView carNumber,castTime,startPoint,endPoint,
	orderCharge,robOrder_title;
	private ImageView robOrder,callImg,messageImg,video,photo;
	private Button confirmOrder,giveUp;
	private LinearLayout videoPhotoMode,contactMode,returnBack;

	private MapView myMap;
	private BaiduMap mBaiduMap;
	private double startLat,startLon,endLat,endLon;
	private String currentLocation;
	private RoutePlanSearch planSearch;
//	private OverlayManager routeOverlay;
//	private RouteLine route;
	private boolean isRobbed;
	private DrivingRouteResult nowResultd  = null;
	private ProgressDialog dialog ;
	private Handler handler=new Handler(){
		public void handleMessage(android.os.Message msg) {
			if(dialog!=null){
				dialog.dismiss();
			}
			switch (msg.what) {
			case -1:
				showShortToast((String) msg.obj);
				break;

			case 1:
				ResponseMsg confirm=new ResponseMsg();
				confirm=(ResponseMsg) msg.obj;
				if(confirm.getCode().equals("1")){
					robOrder_title.setText(R.string.orderSuccess);
//					contactMode.setVisibility(View.VISIBLE);
//					videoPhotoMode.setVisibility(View.VISIBLE);
//					confirmOrder.setVisibility(View.GONE);
//					confirmOrder.setClickable(false);
					isRobbed=true;
					confirmOrder.setText("确认到达");
					robOrder.setImageResource(R.drawable.icon_scrambled);
				}else if(confirm.getCode().equals("2")){
					ExitUtils.Unlogin(OrderConfirmActivity.this, confirm.getMessages());
					return;
				}
				showShortToast(confirm.getMessages());
				break;

			case 0:
				ResponseMsg abond=new ResponseMsg();
				abond=(ResponseMsg) msg.obj;
				if(abond.getCode().equals("1")){
//					robOrder_title.setText(R.string.robOrder);
//					contactMode.setVisibility(View.GONE);
//					videoPhotoMode.setVisibility(View.GONE);
//					confirmOrder.setVisibility(View.VISIBLE);
//					confirmOrder.setClickable(true);
//					robOrder.setImageResource(R.drawable.icon_scramble);
					finish();
				}else if(abond.getCode().equals("2")){
					ExitUtils.Unlogin(OrderConfirmActivity.this, abond.getMessages());
					return;
				}
				showShortToast(abond.getMessages());
				break;

			case 2:
				
				break;

			case 3:
				DataVO dataVO=new DataVO();
				dataVO=(DataVO) msg.obj;
//				dialog.dismiss();
				if(dataVO.getResultCde().equals("1")){
					showShortToast("视频系统连接成功!");
					ReturnSubVideoSrvyVO returnSubVideoSrvyVO = new ReturnSubVideoSrvyVO();
//					returnSubVideoSrvyVO=(ReturnSubVideoSrvyVO) msg.obj;
					returnSubVideoSrvyVO = (ReturnSubVideoSrvyVO)dataVO.getList().get(0);
					intent = new Intent(OrderConfirmActivity.this, VideoActivity.class);
					intent.putExtra("returnSubVideoSrvyVO",returnSubVideoSrvyVO);
					startActivity(intent);
//					finish();
				}else{ //if(dataVO.getResultCde().equals("0")){

					showShortToast(dataVO.getMessage());
				//}else if(dataVO.getResultCde().equals("2")){
					//ExitUtils.Unlogin(OrderConfirmActivity.this, dataVO.getMessage());
				}
				
				break;

			case 5:
				DataVO dataVo=new DataVO();
				dataVo=(DataVO) msg.obj;
//				dialog.dismiss();
				if(dataVo.getResultCde().equals("1")){
					showShortToast("拍照系统连接成功!");
					ReturnSubVideoSrvyVO returnSubVideoSrvyVo = new ReturnSubVideoSrvyVO();
					returnSubVideoSrvyVo = (ReturnSubVideoSrvyVO)dataVo.getList().get(0);
					intent=new Intent(OrderConfirmActivity.this, SelectCarActivity.class);
					intent.putExtra("returnSubVideoSrvyVO",returnSubVideoSrvyVo);
					startActivity(intent);
//					finish();
				}else{
					showShortToast(dataVo.getMessage());
				}
				break;

			case 4:
				showShortToast((String) msg.obj);
//				dialog.dismiss();
				break;

			default:
				break;
			}

		};
	};
	private SharedPreferences prefer;
	private String realName;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_orderconfirm);
		init();
		initView();
	}

	private void initView(){
		robOrder=find(R.id.robOrder);
		carNumber=find(R.id.carNumber);
		castTime=find(R.id.castTime);
		startPoint=find(R.id.startPoint);
		endPoint=find(R.id.endPoint);
		orderCharge=find(R.id.orderCharge);
		callImg=find(R.id.callImg);
		callImg.setOnClickListener(this);
		messageImg=find(R.id.messageImg);
		messageImg.setOnClickListener(this);
		giveUp=find(R.id.giveUp);
		giveUp.setOnClickListener(this);
		video=find(R.id.video);
		video.setOnClickListener(this);
		photo=find(R.id.photo);
		photo.setOnClickListener(this);

		robOrder_title=find(R.id.robOrder_title);
		confirmOrder=find(R.id.confirmOrder);
		videoPhotoMode=find(R.id.videoPhotoMode);
		contactMode=find(R.id.contactMode);
		returnBack=find(R.id.returnBack);
		confirmOrder.setOnClickListener(this);
		returnBack.setOnClickListener(this);

		deviceId=MightypleUtil.getDeviceId(this);

		intent=getIntent();
		orderType=intent.getStringExtra("orderType");
		//		setData(orderType);
		if(orderType.equals(Constants.ROBBED_ORDER)){
			grbaOrder=(grabList) intent.getExtras().get("order");
			endLat=Float.parseFloat(grbaOrder.getLatitude());
			endLon=Float.parseFloat(grbaOrder.getLongitude());
			setData(Constants.ROBBED_ORDER);
			isRobbed=true;
		}else if(orderType.equals(Constants.ROBBING_ORDER)){
			grbaPondOrder=(grabPondList) intent.getExtras().get("order");
			endLat=Float.parseFloat(grbaPondOrder.getLatitude());
			endLon=Float.parseFloat(grbaPondOrder.getLongitude());
			setData(Constants.ROBBING_ORDER);
			isRobbed=false;
		}

		prefer=getSharedPreferences("user", Context.MODE_PRIVATE);
		realName=prefer.getString("realName", "");
		phoneNumber=prefer.getString("phoneNumber", "");
		
		prefer=getSharedPreferences("location", Context.MODE_PRIVATE);
		startLon=Float.parseFloat(prefer.getString("longitude", ""));
		startLat=Float.parseFloat(prefer.getString("latitude", ""));
		String adress=prefer.getString("adress", "");
		String Poi=prefer.getString("Poi", "");
		if(Poi.equals("")){
			currentLocation=adress;
		}else{
			currentLocation=Poi;
		}
		startPoint.setText("从\t"+currentLocation);
		
		//定义Maker坐标点  
		LatLng point = new LatLng(startLat, startLon);  
		//构建Marker图标  
		BitmapDescriptor bitmap = BitmapDescriptorFactory  
				.fromResource(R.drawable.icon_st);  
		//构建MarkerOption，用于在地图上添加Marker  
		OverlayOptions option = new MarkerOptions()  
				.position(point)  
				.icon(bitmap);  
		//在地图上添加Marker，并显示  
		mBaiduMap.addOverlay(option);
		

			searchLines();


	}

	private void init(){

		myMap=find(R.id.myMap);
		mBaiduMap=myMap.getMap();
		myMap.removeViewAt(1); // 去掉百度logo
		myMap.showZoomControls(false);
		planSearch = RoutePlanSearch.newInstance();
		planSearch.setOnGetRoutePlanResultListener(this);

	}
	/**
	 * 发起路线规划搜索示例
	 *
	 */
	private void searchLines(){
//		route = null;

		LatLng start = new LatLng(startLat, startLon);  
		LatLng end = new LatLng(endLat, endLon); 
		PlanNode startNode=PlanNode.withLocation(start);
		PlanNode endNode=PlanNode.withLocation(end);

		planSearch.drivingSearch((new DrivingRoutePlanOption())
				.from(startNode).to(endNode));
	}


	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		myMap.onResume();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		myMap.onPause();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		myMap.onDestroy();
		new VoiceUtil("", OrderConfirmActivity.this).VoiceStop();
		planSearch.destroy();
	}


	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.returnBack:
			finish();
			break;

		case R.id.confirmOrder:
			if(isRobbed){
				new AlertDialog.Builder(OrderConfirmActivity.this, AlertDialog.THEME_HOLO_LIGHT)
				.setTitle("提示")
				.setMessage("请确认您是否已达到目的地！如果是，请开始视频查勘作业！当网络环境不佳时，请切换至拍照查勘模式！")
				.setPositiveButton("已到达", new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						contactMode.setVisibility(View.VISIBLE);
						videoPhotoMode.setVisibility(View.VISIBLE);
						confirmOrder.setVisibility(View.GONE);
					}
				})
				.setNegativeButton("取消", new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						
					}
				})
				.create()
				.show();
			}else{
				RequestGrab requestGrab;
//				if(grbaPondOrder!=null){
					requestGrab=new RequestGrab(deviceId, grbaPondOrder.getUserId(), grbaPondOrder.getCaseNumber(), 
							grbaPondOrder.getTaskNumber(),TimeUtils.getLeftTime(grbaPondOrder.getUpdateTime(), TimeUtils.getCurentTime(), grbaPondOrder.getLeftTime())/1000+"", grbaPondOrder.getPredictCharge(), grbaPondOrder.getDistance(),
							grbaPondOrder.getLongitude(), grbaPondOrder.getLatitude(), 
							currentLocation);
//				}else{
//					requestGrab=new RequestGrab(deviceId, grbaOrder.getUserId(), grbaOrder.getCaseNumber(), 
//							grbaOrder.getTaskNumber(),grbaOrder.getLeftTime(), grbaOrder.getPredictCharge(), grbaOrder.getDistance(),
//							grbaOrder.getLongitude(), grbaOrder.getLatitude(), 
//							currentLocation);
//				}
				new GrabOrderThread(OrderConfirmActivity.this, handler, requestGrab).start();
				
			}
			
			break;

		case R.id.callImg:
			if(grbaOrder!=null){
				intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+grbaOrder.getReportPhone()));
			}else if(grbaPondOrder!=null){
				intent=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+grbaPondOrder.getReportPhone()));
			}
			
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			startActivity(intent);
			break;

		case R.id.messageImg:
			if(grbaOrder!=null){
				intent = new Intent( android.content.Intent.ACTION_SENDTO, Uri.parse("smsto:"+grbaOrder.getReportPhone()) );
			}else if(grbaPondOrder!=null){
				intent = new Intent( android.content.Intent.ACTION_SENDTO, Uri.parse("smsto:"+grbaPondOrder.getReportPhone()) );
			}
			
			startActivity( intent );
			break;

		case R.id.giveUp:
			
			new AlertDialog.Builder(OrderConfirmActivity.this, AlertDialog.THEME_HOLO_LIGHT)
			.setTitle("提示")
			.setMessage("是否放弃抢单？")
			.setPositiveButton("是", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// TODO Auto-generated method stub
					RequestAbond requestAbond=null;
					if(grbaOrder!=null){
						requestAbond=new RequestAbond(deviceId, grbaOrder.getUserId(), grbaOrder.getId(), grbaOrder.getCaseNumber(), grbaOrder.getTaskNumber());
					}else{
						requestAbond=new RequestAbond(deviceId, grbaPondOrder.getUserId(), grbaPondOrder.getId(), grbaPondOrder.getCaseNumber(), 
								grbaPondOrder.getTaskNumber());
					}
					new AbondOrderThread(OrderConfirmActivity.this, handler, requestAbond).start();
					dialog= ProgressDialog.show(OrderConfirmActivity.this,null,"正在放弃订单，请稍等…",false,true);

				}
			})
			.setNegativeButton("否", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// TODO Auto-generated method stub
					
				}
			})
			.create().show();
			
//			dialog= ProgressDialog.show(OrderConfirmActivity.this,null,"正在放弃订单，请稍等…",false,true);

			break;

		case R.id.video:
			
			DataVO dataVO = new DataVO();
			dataVO.setAction("QAndroidSubmitVideoSrvy");
			dataVO.setMethod("pdaSubmitVideoSrvy");
			List<VOBase> lists = new ArrayList<VOBase>();
			SubmitVideoSrvyVO submitVideoSrvyVO = new SubmitVideoSrvyVO();
			if(grbaOrder!=null){
				submitVideoSrvyVO.setCarNo(grbaOrder.getTargetCar());
				submitVideoSrvyVO.setCaseType("1001");
				submitVideoSrvyVO.setClaimTaskId(grbaOrder.getTaskNumber());
				submitVideoSrvyVO.setClaimTaskType("3");
				submitVideoSrvyVO.setClientType("");
				submitVideoSrvyVO.setCompanyNme("");
				submitVideoSrvyVO.setMbOperateFlag("1");
				submitVideoSrvyVO.setPlyDptCde(grbaOrder.getPollcyDeptCode());
				submitVideoSrvyVO.setPlyDptNme(grbaOrder.getPollcyDeptName());
				submitVideoSrvyVO.setPressLevel("");
				submitVideoSrvyVO.setSetLossMark("");
				submitVideoSrvyVO.setSryCde(phoneNumber);
				submitVideoSrvyVO.setSryNme(realName);
				submitVideoSrvyVO.setTaskNo(grbaOrder.getCaseNumber());
				submitVideoSrvyVO.setLatitude("");
				submitVideoSrvyVO.setLongitude("");
				submitVideoSrvyVO.setDeviceType("1");
				submitVideoSrvyVO.setOperationType("0");
			}else if(grbaPondOrder!=null){
				submitVideoSrvyVO.setCarNo(grbaPondOrder.getTargetCar());
				submitVideoSrvyVO.setCaseType("1001");
				submitVideoSrvyVO.setClaimTaskId(grbaPondOrder.getTaskNumber());
				submitVideoSrvyVO.setClaimTaskType("3");
				submitVideoSrvyVO.setClientType("");
				submitVideoSrvyVO.setCompanyNme("");
				submitVideoSrvyVO.setMbOperateFlag("1");
				submitVideoSrvyVO.setPlyDptCde(grbaPondOrder.getPollcyDeptCode());
				submitVideoSrvyVO.setPlyDptNme(grbaPondOrder.getPollcyDeptName());
				submitVideoSrvyVO.setPressLevel("");
				submitVideoSrvyVO.setSetLossMark("");
				submitVideoSrvyVO.setSryCde(phoneNumber);
				submitVideoSrvyVO.setSryNme(realName);
				submitVideoSrvyVO.setTaskNo(grbaPondOrder.getCaseNumber());
				submitVideoSrvyVO.setLatitude("");
				submitVideoSrvyVO.setLongitude("");
				submitVideoSrvyVO.setDeviceType("1");
				submitVideoSrvyVO.setOperationType("0");
			}
//			DataVO dataVO = new DataVO();
//            dataVO.setAction("QAndroidSubmitVideoSrvy");
//            dataVO.setMethod("pdaSubmitVideoSrvy");
//            List<VOBase> lists = new ArrayList<VOBase>();
//            SubmitVideoSrvyVO submitVideoSrvyVO = new SubmitVideoSrvyVO();
//            submitVideoSrvyVO.setCarNo("京GEB059");
//            submitVideoSrvyVO.setCaseType("1001");
//            submitVideoSrvyVO.setClaimTaskId("1479697260391");
//            submitVideoSrvyVO.setClaimTaskType("3");
//            submitVideoSrvyVO.setClientType("");
//            submitVideoSrvyVO.setCompanyNme("");
//            submitVideoSrvyVO.setMbOperateFlag("1");
//            submitVideoSrvyVO.setPlyDptCde("11000000");
//            submitVideoSrvyVO.setPlyDptNme("北京市分公司");
//            submitVideoSrvyVO.setPressLevel("");
//            submitVideoSrvyVO.setSetLossMark("");
//            submitVideoSrvyVO.setSryCde("13140448176");
//            submitVideoSrvyVO.setSryNme("夏博文");
//            submitVideoSrvyVO.setTaskNo("705072016110000000140");
//            lists.add(submitVideoSrvyVO);
//            dataVO.setList(lists);

			lists.add(submitVideoSrvyVO);
			dataVO.setList(lists);

			dialog= ProgressDialog.show(OrderConfirmActivity.this,null,"正在连接视频系统",false,true);

			new VideoThread(dataVO, handler).start();
			//            OkHttpProxy.postData().url(Constants.VIDEO_SERVICE).setDataXml(dataVO).enqueue(new OkCallback<DataVO>(new OkXmlParser<DataVO>() {
			//            }) {
			//
			//
			//				@Override
			//				public void onSuccess(int code, DataVO dataVO) {
			//					// TODO Auto-generated method stub
			//					if(dataVO.getResultCde().equals("1")){
			//                        ReturnSubVideoSrvyVO returnSubVideoSrvyVO = (ReturnSubVideoSrvyVO)dataVO.getList().get(0);
			//                        intent = new Intent(OrderConfirmActivity.this, VideoActivity.class);
			//                        intent.putExtra("returnSubVideoSrvyVO",returnSubVideoSrvyVO);
			//                        startActivity(intent);
			//                        dialog.dismiss();
			//                        finish();
			//					}
			//					
			//				}
			//
			//				@Override
			//				public void onFailure(Throwable e) {
			//					// TODO Auto-generated method stub
			//					LogUtil.i("111",e.getMessage());
			//                    dialog.dismiss();
			//				}
			//
			//                
			//            });
			break;

		case R.id.photo:
			
			DataVO dataVo = new DataVO();
			dataVo.setAction("QAndroidSubmitVideoSrvy");
			dataVo.setMethod("pdaSubmitVideoSrvy");
			List<VOBase> lists1 = new ArrayList<VOBase>();
			SubmitVideoSrvyVO submitVideoSrvyVo = new SubmitVideoSrvyVO();
			if(grbaOrder!=null){
				submitVideoSrvyVo.setCarNo(grbaOrder.getTargetCar());
				submitVideoSrvyVo.setCaseType("1001");
				submitVideoSrvyVo.setClaimTaskId(grbaOrder.getTaskNumber());
				submitVideoSrvyVo.setClaimTaskType("3");
				submitVideoSrvyVo.setClientType("");
				submitVideoSrvyVo.setCompanyNme("");
				submitVideoSrvyVo.setMbOperateFlag("1");
				submitVideoSrvyVo.setPlyDptCde(grbaOrder.getPollcyDeptCode());
				submitVideoSrvyVo.setPlyDptNme(grbaOrder.getPollcyDeptName());
				submitVideoSrvyVo.setPressLevel("");
				submitVideoSrvyVo.setSetLossMark("");
				submitVideoSrvyVo.setSryCde(phoneNumber);
				submitVideoSrvyVo.setSryNme(realName);
				submitVideoSrvyVo.setTaskNo(grbaOrder.getCaseNumber());
				submitVideoSrvyVo.setLatitude("");
				submitVideoSrvyVo.setLongitude("");
				submitVideoSrvyVo.setDeviceType("1");
				submitVideoSrvyVo.setOperationType("1");
			}else if(grbaPondOrder!=null){
				submitVideoSrvyVo.setCarNo(grbaPondOrder.getTargetCar());
				submitVideoSrvyVo.setCaseType("1001");
				submitVideoSrvyVo.setClaimTaskId(grbaPondOrder.getTaskNumber());
				submitVideoSrvyVo.setClaimTaskType("3");
				submitVideoSrvyVo.setClientType("");
				submitVideoSrvyVo.setCompanyNme("");
				submitVideoSrvyVo.setMbOperateFlag("1");
				submitVideoSrvyVo.setPlyDptCde(grbaPondOrder.getPollcyDeptCode());
				submitVideoSrvyVo.setPlyDptNme(grbaPondOrder.getPollcyDeptName());
				submitVideoSrvyVo.setPressLevel("");
				submitVideoSrvyVo.setSetLossMark("");
				submitVideoSrvyVo.setSryCde(phoneNumber);
				submitVideoSrvyVo.setSryNme(realName);
				submitVideoSrvyVo.setTaskNo(grbaPondOrder.getCaseNumber());
				submitVideoSrvyVo.setLatitude("");
				submitVideoSrvyVo.setLongitude("");
				submitVideoSrvyVo.setDeviceType("1");
				submitVideoSrvyVo.setOperationType("1");
			}

			lists1.add(submitVideoSrvyVo);
			dataVo.setList(lists1);

			dialog= ProgressDialog.show(OrderConfirmActivity.this,null,"正在连接拍照系统",false,true);

			new PhotoThread(dataVo, handler).start();

			break;


		default:
			break;
		}
	}

	private void setData(String orderType){
		if(orderType.equals(Constants.ROBBED_ORDER)){

			grbaOrder=(grabList) intent.getExtras().get("order");
			carNumber.setText(grbaOrder.getTargetCar());
			castTime.setText(TimeUtils.EnglishToChinese(grbaOrder.getUpdateTime()));

			endPoint.setText("到\t"+grbaOrder.getOccurPlace());
			orderCharge.setText(grbaOrder.getPredictCharge());

			robOrder_title.setText(R.string.orderSuccess);
//			contactMode.setVisibility(View.VISIBLE);
//			videoPhotoMode.setVisibility(View.VISIBLE);
//			confirmOrder.setVisibility(View.GONE);
//			confirmOrder.setClickable(false);
			confirmOrder.setText("确认到达");
			robOrder.setImageResource(R.drawable.icon_scrambled);
		}else if(orderType.equals(Constants.ROBBING_ORDER)){

			grbaPondOrder=(grabPondList) intent.getExtras().get("order");
			carNumber.setText(grbaPondOrder.getTargetCar());
			castTime.setText(TimeUtils.EnglishToChinese(grbaPondOrder.getUpdateTime()));

			endPoint.setText("到\t"+grbaPondOrder.getOccurPlace());
			orderCharge.setText(grbaPondOrder.getPredictCharge());

			robOrder_title.setText(R.string.robOrder);
//			contactMode.setVisibility(View.GONE);
//			videoPhotoMode.setVisibility(View.GONE);
//			confirmOrder.setVisibility(View.VISIBLE);
//			confirmOrder.setClickable(true);
			confirmOrder.setText("确认抢单");
			robOrder.setImageResource(R.drawable.icon_scramble);
		}
	}

	@Override
	public void onGetBikingRouteResult(BikingRouteResult arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onGetDrivingRouteResult(DrivingRouteResult resul) {
		// TODO Auto-generated method stub
		if (resul == null) {  
			Toast.makeText(OrderConfirmActivity.this, "抱歉，未找到结果", Toast.LENGTH_LONG).show();  
			return;  
		}  
		// 叠加路线到地图显示，此处仅展示一个方案作为示例  
		if (resul.error == SearchResult.ERRORNO.NO_ERROR) {
			//			route = resul.getRouteLines().get(0);
			//            DrivingRouteOverlay overlay = new DrivingRouteOverlay(mBaidumap);
			//            routeOverlay = overlay;
			//            mBaidumap.setOnMarkerClickListener(overlay);
			//            overlay.setData(resul.getRouteLines().get(0));
			//            overlay.addToMap();
			//            overlay.zoomToSpan();

			if (resul.getRouteLines().size() > 1 ) {
				nowResultd = resul;

//				route = nowResultd.getRouteLines().get(0);
				DrivingRouteOverlay overlay = new DrivingRouteOverlay(mBaiduMap);
				mBaiduMap.setOnMarkerClickListener(overlay);
//				routeOverlay = overlay;
				overlay.setData(nowResultd.getRouteLines().get(0));
				overlay.addToMap();
				overlay.zoomToSpan();
				new VoiceUtil("路线规划成功", OrderConfirmActivity.this).VoicePlay();
			} else if ( resul.getRouteLines().size() == 1 ) {
//				route = resul.getRouteLines().get(0);
				DrivingRouteOverlay overlay = new DrivingRouteOverlay(mBaiduMap);
//				routeOverlay = overlay;
				mBaiduMap.setOnMarkerClickListener(overlay);
				overlay.setData(resul.getRouteLines().get(0));
				overlay.addToMap();
				overlay.zoomToSpan();
				new VoiceUtil("路线规划成功", OrderConfirmActivity.this).VoicePlay();
				
			}
		}
	}

	@Override
	public void onGetTransitRouteResult(TransitRouteResult arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onGetWalkingRouteResult(WalkingRouteResult arg0) {
		// TODO Auto-generated method stub

	}

}
